<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!--我的订单页面 -->
<!DOCTYPE html>
<html>
<head>

<title>修改登录密码</title>
<link href="css/order_my.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-2.1.1.js"></script>
<script type="text/javascript" src="js/jquery-1.10.2.js"></script>
<script type="text/javascript">
var ok=false;
var ok1=false;
function check(){
		
		$.ajax({
			Type:"POST",
			url:"UpdatePsw.action?method=psw",
			success:function(response,status,xhr){
			var result=xhr.responseText;
				var pass=eval('('+result+')');
				if($('.psw').val()!=pass.userPassword)
				{	
					$('.word').css('display','block');
				}else{
					ok=true;
					$('.word').css('display','none');
				}
			}
		});
	}
	 function checkpsw(){
		
		var str=$('.pss').val();
		var ret =/^[a-zA-Z][a-zA-Z0-9]{5,20}$/;
		if(ret.test(str)){
		ok1=true;
		
			$('.news').css('display','none');
		}
		else{
			$('.news').css('display','block');
		}
	}
	
	function submits(){
		if(ok&&ok1){
			$.ajax({
				Type:"POST",
				url:"password.action?method=modifys",
				data:{'psws':$('.pss').val()},
				success:function(response,status,xhr){
					if(response==1){
						var url="${pageContext.request.contextPath}/user_manage/user_login.jsp";
						window.top.location=url;						
					}
					
				}
			});
			
		}else if(ok){
		alert("请输入正确的新密码！");
		}else{
		alert("请输入正确的原密码！");
		}
	}
	
	
	

</script>
</head>
<body>
  
  <div id="nav">
     <span>您的位置： </span>
     <span style="color:#16a085">修改登录密码</span>
  </div>
 
 <table width="100%" border="0" cellspacing="0" cellpadding="0" id="shopping">
  <tr>
    <td colspan="8" rowspan="8"  class="line"></td>
  </tr>
  </table>
  </div>
 
<br/>
<br/>

 <div id="content"> 
 <form action="" method="post">
<table id="shopping">
<tr>
    <td class="goods"><h2>旧密码：</h2></td>
    <td><input type="password" class="psw" onmouseout="check();"/></td>
    <td><div class="word" style="display:none"><p>请输入正确的密码！</p></div></td>
  </tr>
  
  <tr>
    <td class="goods"><h2>新密码：</h2></td>
    <td><input type="password" name="psws" class="pss" onmouseout="checkpsw();"/></td>
    <td><div class="news" style="display:none"><p>密码首位为字母，且由5位以上字母，数字组成！</p></div></td>
  </tr>
  <tr>
  <td class="goods"></td>
    <td class="goods"><input type="button" value="提交" class="btn" onclick="submits();"/>
   <input type="reset" value="重置"/></td>
  </tr>
  
 
	</table>
	</form>

</body>
</html>
